package org.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ServletTest extends HttpServlet {
	private static final long serialVersionUID = 6798918192289075090L;

	protected void service(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

		System.out.println("---------------------request--------------------");
		System.out.println("requestURI:" + req.getRequestURI());
		System.out.println("requestURL:" + req.getRequestURL());
		System.out.println("contentLength:" + req.getContentLength());
		System.out.println("contentType:" + req.getContentType());
		System.out.println("Method:" + req.getMethod());
		System.out.println("Host:" + req.getParameter("Host"));
		System.out.println("contextPath:" + req.getContextPath());
		System.out.println("servletPath:" + req.getServletPath());
		System.out.println("characterEncoding:" + req.getCharacterEncoding());
		req.setCharacterEncoding("utf-8");
		System.out.println("characterEncoding:" + req.getCharacterEncoding());
		System.out.println("-----------------------------------------------");

		System.out.println("---------------------response------------------");
		System.out.println("PrintWriter:" + resp.getWriter());
		resp.setStatus(200);
		System.out.println("stateCode:" + resp.getStatus());
		System.out.println("-----------------------------------------------");
		System.out.println("-----------------------Other-------------------");
		System.out.println(req.getAuthType());
		System.out.println(req.getLocalAddr());
		System.out.println(req.getLocalName());
		System.out.println(req.getLocalPort());
		System.out.println(req.getPathInfo());
		System.out.println(req.getSession());
		System.out.println(req.getUserPrincipal());
		System.err.println(req.getServletContext());
		System.out.println(req.getReader());
		System.out.println(req.getParts());
		System.out.println(req.getParameterNames());
		System.out.println(req.getParameterMap());
		System.out.println("------------------------------------------------");
	}

}
